package cn.lili.modules.grab.xdxt.reps.order;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OrderFreightPreviewReps {

    private int code;
    private String msg;
    private Result result;
    private String traceId;

    @Data
    public static class Result {
        @ApiModelProperty("订单运费")
        private double freight;
        @ApiModelProperty("商品总额")
        private double goodsMoneyAmount;
        @ApiModelProperty("支付总额")
        private double payMoney;
    }

    /**
     * 将JSON构建为ListGoodsReps
     *
     * @param jsonString 值
     */
    public static OrderFreightPreviewReps builderOrderFreightPreviewReps(JSONObject jsonString) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        OrderFreightPreviewReps orderFreightPreviewReps = mapper.readValue(jsonString.toString(), OrderFreightPreviewReps.class);
        return orderFreightPreviewReps;
    }
}
